
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

import javax.swing.JOptionPane;
import javax.swing.JTabbedPane;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JPasswordField;

public class Entrada extends JFrame {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private JPanel contentPane;
	private JTextField textField = null;

	private JPasswordField passwordField;
	private final String usuario = "usuario";
	private final String contraseña = "12345";

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					Entrada frame = new Entrada();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public Entrada() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);

		JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
		tabbedPane.setBounds(0, 0, 434, 262);
		contentPane.add(tabbedPane);

		JPanel panel = new JPanel();
		tabbedPane.addTab("Entrar", null, panel, null);
		panel.setLayout(null);
		this.setTitle(" Ejemplo SVN ");

		JLabel lblUsername = new JLabel("Username: ");
		lblUsername.setBounds(113, 62, 81, 14);
		panel.add(lblUsername);

		JLabel lblPassword = new JLabel("Password: ");
		lblPassword.setBounds(113, 103, 69, 14);
		panel.add(lblPassword);

		textField = new JTextField();
		textField.setBounds(204, 59, 86, 20);
		panel.add(textField);
		textField.setColumns(10);

		passwordField = new JPasswordField();
		passwordField.setBounds(204, 100, 85, 20);
		panel.add(passwordField);

		JButton btnIngresar = new JButton("Ingresar");

		btnIngresar.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {

				try {

					String username = null, password = null;

					if (textField.getText().length() > 0
							&& passwordField.getText().length() > 0) {
						username = textField.getText();
						password = passwordField.getText();

						if (usuario.equalsIgnoreCase(username)
								&& contraseña.equalsIgnoreCase(password)) {

							JOptionPane.showMessageDialog(null,
									"  Bienvenido :) ");
						} else

						if (!usuario.equals(username)) {
							JOptionPane.showMessageDialog(null,
									"ERROR: El usuario no existe");
						}

						if (!contraseña.equals(password)) {
							JOptionPane.showMessageDialog(null,
									"ERROR: password incorrecto");
						}
					}

				}

				catch (NumberFormatException ernum) {
					JOptionPane
							.showMessageDialog(
									null,
									"Error en tipo de formato de alguna casilla, por favor verifique que dentro de las casillas de solo numero no exista alg�n tipo de letra o simbolo.\n"
											+ ernum.getMessage());
				} catch (Exception err) {
					JOptionPane.showMessageDialog(null, "Error General!");
				}
			}
		});

		btnIngresar.setBounds(153, 159, 89, 23);
		panel.add(btnIngresar);

	}
}
